<template>
  <bg-vue>
    <template #imgFixed>
      <!-- <img src="@/assets/imgV2/walletGm-bg-bottom.jpg" /> -->
      <img src="@/assets/imgV2/exchange-bg-bottom.jpg" />
    </template>
    <template #img>
      <img src="@/assets/imgV2/walletGm-bg.png" />
    </template>
    <div class="walletGm">
      <div class="tit">
        {{ t('walletGm.title') }}
      </div>
      <div class="tabs">
        <button
          @click="tabCoin('PLAY')"
          :class="{ active: coin === 'PLAY' }"
          class="l"
          >PLAY</button
        >
        <button
          @click="tabCoin('PT')"
          :class="{ active: coin === 'PT' }"
          class="r"
          >PT</button
        >
      </div>
      <div class="info">
        <div class="name">{{ coin }} {{ t('walletGm.KY') }}</div>
        <div class="value">{{ coin === 'PT' ? gm : at }}</div>
      </div>
      <div class="link">
        <router-link :to="{ path: '/fundingDetails', query: { coin } }">{{
          t('walletGm.ZJMX')
        }}</router-link>
      </div>
      <div class="btns">
        <van-button color="#ff9800" to="recharge">{{
          t('walletGm.recharge')
        }}</van-button>
        <van-button color="#000" to="withdraw">{{
          t('walletGm.extract')
        }}</van-button>
      </div>
    </div>
  </bg-vue>
</template>
<script>
import http from '../http'
import BgVue from '@/components/BgVue.vue'
import removeZeros from '@/utils/remove-zeros'
export default {
  data() {
    return {
      gm: 0,
      at: 0,
      coin: 'PLAY',
      ableNum: 0,
      unableNum: 0,
      // list: [],
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    tabCoin(coin) {
      this.coin = coin
      // this.list = []
      this.init()
    },
    async init() {
      const res = await http.get('/api/user/moneyLog')
      if (res.code === 200) {
        this.gm = removeZeros(res.data.gm)
        this.at = removeZeros(res.data.at)
        // this.list = res.data.logs
        //   .map((row) => {
        //     var value = this.coin === 'PT' ? row.gm : row.at
        //     if (value * 1 === 0) {
        //       return null
        //     }
        //     return {
        //       time: row.create_time,
        //       value: (value > 0 ? '+' : '') + value,
        //       note: row.note,
        //       type: 2,
        //     }
        //   })
        //   .filter((row) => row !== null)

        // if (process.env.NODE_ENV !== 'production') {
        //   this.list = this.list.concat([
        //     {
        //       time: '20220202',
        //       value: 123,
        //       note: 'xxxx',
        //       type: 2,
        //     },
        //     {
        //       time: '20220202',
        //       value: 123,
        //       note: 'xxxx',
        //       type: 2,
        //     },
        //   ])
        // }
      }
    },
  },
  components: { BgVue },
}
</script>
<style lang="less" scoped>
.walletGm {
  .tit {
    height: 163px;
    padding: 132px 42px 0 56px;
    color: #ffc53d;
    font-size: 24px;
    text-align: center;
    text-shadow: 1px 2px 0px rgba(10, 2, 4, 0.2);
    font-weight: bold;
  }
  .tabs {
    display: flex;
    justify-content: space-between;
    padding: 42px 50px 0;
    padding: 44px 50px 0;
    button {
      width: 123px;
      height: 50px;

      border: none;
      color: #fff;
      font-size: 19px;
      border-radius: 12px;
    }
    button.active {
      background-image: linear-gradient(0deg, #fe7d27 0%, #ffdc43 100%),
        linear-gradient(#fbba1e, #fbba1e);

      text-shadow: #d8540d 1px 0 2px, #d8540d 0 1px 2px, #d8540d -1px 0 2px,
        #d8540d 0 -1px 2px;
    }
    button + button {
      margin-right: -1px;
    }
  }

  .info {
    display: flex;
    justify-content: space-between;
    height: 44px;

    padding: 24px 52px 0 60px;

    color: #ffffff;
    font-size: 15px;
  }
  .link {
    padding: 26px 50px;
    color: #117fd4;
    font-size: 16px;
    font-weight: bold;
    a {
      display: block;
      width: 280px;
      height: 43px;
      color: inherit;
      line-height: 45px;
      text-align: left;
      padding-left: 10px;
    }
  }
  .btns {
    display: flex;
    justify-content: space-between;
    padding: 15px 46px;
    .van-button {
      display: block;
      width: 120px;
      height: 42px;

      color: #ffffff;
      font-size: 17px;

      text-shadow: #d8540d 1px 0 2px, #d8540d 0 1px 2px, #d8540d -1px 0 2px,
        #d8540d 0 -1px 2px;
      background-color: transparent !important;
      border: none;
      background-image: linear-gradient(0deg, #fe7d27 0%, #ffdc43 100%);
      // font-weight: bold;
    }
    .van-button + .van-button {
      text-shadow: #146092 1px 0 2px, #146092 0 1px 2px, #146092 -1px 0 2px,
        #146092 0 -1px 2px;
    }
  }
}
</style>
